package org.shoukaiseki.supersaiyan.db.inittable.generator;


import org.shoukaiseki.inittable.domain.TableColumnInfo;
import org.shoukaiseki.inittable.service.ITableBuildInfoService;
import org.shoukaiseki.kakaroto.annotation.TableBuild;
import org.shoukaiseki.supersaiyan.common.constant.GenConstants;

import java.util.List;

import static org.shoukaiseki.inittable.utils.SksColumnCamelCaseCommon.*;
import static org.shoukaiseki.inittable.utils.TableColumnInfoBuilder.column;
import static org.shoukaiseki.inittable.utils.TableInfoUtils.tableColumns;


/**
 * OK
 * org.shoukaiseki.supersaiyan.db.inittable.generator.GenTableInitTableInfo
 * <br>
 *
 * @author shoukaiseki blog http://www.shoukaiseki.top/<br> E-mail jiang28555@Gmail.com<br>
 * @date 2022-10-10 19:37:40<br>
 */
@TableBuild(name = "gen_table", comment = "代码生成业务表",version = 1)
public class GenTableInitTableInfo implements ITableBuildInfoService {


    @Override
    public List<TableColumnInfo> tableColumnInfoList(){
        List<TableColumnInfo> table = tableColumns(

                uniqueId("table_id","编号"),
                column("	table_name          varchar(200)    default ''     null comment '表名称',"),
                column("	table_comment       varchar(500)    default ''     null comment '表描述',"),
                column("	sub_table_name      varchar(64)                    null comment '关联子表的表名',"),
                column("	sub_table_fk_name   varchar(64)                    null comment '子表关联的外键名',"),
                column("	class_name          varchar(100)    default ''     null comment '实体类名称',"),
                column("	tpl_category        varchar(200)    default '"+ GenConstants.TPL_SKS_CRUD +"' null comment '使用的模板',")
                        .description("（crud单表操作 tree树表操作）"),
                column("	package_name        varchar(100)                   null comment '生成包路径',"),
                column("	module_name         varchar(30)                    null comment '生成模块名',"),
                column("	business_name       varchar(30)                    null comment '生成业务名',"),
                column("	function_name       varchar(50)                    null comment '生成功能名',"),
                column("	function_author     varchar(50)                    null comment '生成功能作者',"),
                column("	gen_type            char            default '0'    null comment '生成代码方式',")
                        .description("（0zip压缩包 1自定义路径）"),
                column("	gen_path            varchar(200)    default '/'    null comment '生成路径',")
                        .description("（不填默认项目路径）"),
                column("	options             varchar(1000)                  null comment '其它生成选项',"),
                column("  mybatis_table_alias varchar(64) DEFAULT 't1' not NULL COMMENT 'mybatis查询时表别名',")
                        .description("${tableName} as ${mybatisTableAlias}"),
                column("	remark              varchar(500)                   null comment '备注',"),
                column("  virtual_delete char(1) DEFAULT '0' COMMENT '虚拟删除',"),
                column("  resource_conf_name  varchar(64) DEFAULT '' not null COMMENT '资源配置名称',"),
                createUserId(),
                createTime(),
                updateUserId(),
                updateTime(),




                null
        );

        return table;
    }

//    @Override
//    public List<TableIndexInfo> tableIndexInfoList() {
//        return tableIndexs(
//                index("inventory_reserved_inventory_bom_id_index").indexColumns("inventory_bom_id"),
//                index("inventory_reserved_item_id_index").indexColumns("item_id"),
//                index("inventory_reserved_inventory_bom_item_id_index").indexColumns("inventory_bom_id,item_id"),
//                null
//        );
//    }
//
//    @Override
//    public List<TableTriggerInfo> tableTriggerList() {
//        return tableTriggers(triggerName("inventory_reserved_rowstamp")
//                .triggerSql("create trigger inventory_reserved_rowstamp before update on inventory_reserved FOR EACH ROW\n" +
//                        "begin\n" +
//                        "    set @rowstamp= old.rowstamp;\n" +
//                        "    set NEW.rowstamp=@rowstamp+1;\n" +
//                        "end;\n"));
//    }
}
